

<div class="container" id="qa">
        <h3 class="wrapTitle">- QUESTIONS & ANSWERS - </h3>
        <h4 class="contboxh4"><a href="javascript://" id="add-question" class="addQuestionSub">ADD QUESTION</a><b>QUESTIONS</b></h4>
       
        <div class="parame-bott cliks-bn" style="display:block" id="ask_tab1">
                <div class="commodity-num" id="ajax_consult_return">
                    <!--ajax return-->
                </div>
            </div>
            <script>
                $(document).ready(function(){
                    consult_type = 0; // 咨询类型
                    ajaxConsult(consult_type,1);// ajax 加载咨询列表
                });
                // 咨询类型切换
                $(".consult_ul a").click(function(){
                    $(".consult_ul li").removeClass('current');
                    $(this).parent().addClass('current');
                    consult_type = $(this).data('t');// 咨询类型 商品咨询 支付咨询 配送咨询 售后咨询
                    ajaxConsult(consult_type,1);
                });

                // 用ajax分页显示咨询
                function ajaxConsult(consult_type,page){
                    $.ajax({
                        type : "GET",
                        url:"/index.php?m=Home&c=Goods&a=ajax_consult&goods_id={$goods['goods_id']}&consult_type="+consult_type+"&p="+page,//+tab,
                        success: function(data){
                            $("#ajax_consult_return").html('');
                            $("#ajax_consult_return").append(data);
                        }
                    });
                }
            </script>
</div>
<div class="postrevBox" id="questionForm" style="display:none;">
<div class="container" style="position:relative;">
        <b class="postClose" id="postClose">X</b>
        <h3 class="wrapTitle">- Ask a Question -</h3>
        <a name="question-form"></a>
        <form action="{:U('Home/Goods/goodsConsult')}" method="post" id="form_consult" name="form_consult" onSubmit="return check_form_consult(this);">
        <div class="postFormBox">
        	<div><b>Question</b><em>*</em></div>
        	<div><textarea name="content" id="content" title="content" class="required-entry input-text" cols="5" rows="3"></textarea></div>
        </div>
        <div class="postFormBoxli clearfix">
            <div class="col-sm-6">
                <b>Nickname<em>*</em></b>
                <div class="input-box">
                    <input name="username" id="username" title="username" value="" class="input-text required-entry" type="text">
                </div>
            </div>
           
            <div class="col-sm-6">
                <b>Email<em>*</em></b>
                <div class="input-box">
                    <input name="email" id="email" title="Email" value="" class="input-text required-entry validate-email" type="text">
                </div>
            </div>
			
			<div class="col-sm-6">
                <b>Code<em>*</em></b>
                <div class="input-box">
                   <div class="input-box">
							<img src="/index.php?m=Home&c=Index&a=verify&type=consult&fontSize=20&length=4" onclick="verify(this)" id="captcha_image">
						</div>
					
					<div class="left">
						<div class="left"><label class="required">Enter the text above<em>*</em></label></div>
						<div class="left">
							<input type="text" name="verify_code" class="required-entry input-text captcha-input" id="verify_code" value="">
						</div>
					</div>
					
					
                </div>
            </div>
			
            <div class="col-sm-12"><hr></div>
            <div class="col-sm-12">You may receive emails regarding this submission. Any emails will include the ability to opt-out of future communications.</div>
            <div class="col-sm-12">
                <input type="hidden" name="goods_id" value="{$goods['goods_id']}">
                <button type="submit" title="Submit" class="button form-button">Post Question</button>
            </div>
        </div>
        </form>  
    </div>
    
     <script>
	 $("#add-question").click(function(){
				if($("#questionForm").css("display")=="none") {
                    $("#questionForm").show();
                }
                else    {
                    $("#questionForm").hide();
                }
			});
	 $("#postClose").click(function(){
                    $("#questionForm").hide();
			});
			
			

                // 商品咨询表单验证
                function check_form_consult(f){
					 if($.trim($('textarea[name="content"]').val()).length == 0)
                    {

                        layer.msg('Question is a required field.', {
                            icon: 1,   // 成功图标
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        });
                        return false;
                    }
                    if($.trim($('input[name="username"]').val()).length == 0)
                    {
                        layer.msg('Nickname is a required field.', {
                            icon: 1,  
                            time: 2000 
                        });

                        return false;
                    }
                    if($.trim($('input[name="email"]').val()).length == 0)
                    {
                        layer.msg('Email is a required field.', {
                            icon: 1,  
                            time: 2000 
                        });

                        return false;
                    }
                   var myreg = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
                    if(!myreg.test($.trim($('input[name="email"]').val())))
                    {
                        layer.msg('Email format is incorrect.', {
                            icon: 1,  
                            time: 2000 
                        });

                        return false;
                    }
                    if($.trim($('input[name="verify_code"]').val()).length == 0)
                    {
                        layer.msg('Code is a required field.', {
                            icon: 1,   // 成功图标
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        });
                        return false;
                    }
                    return true;
                }
				
				
				function verify(){
					$('#captcha_image').attr('src','/index.php?m=Home&c=Index&a=verify&type=consult&fontSize=20&length=4&r='+Math.random());
				}
            </script></div>